package com.chb.friend2;


import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.WritableComparable;

/**
 * 按照用户分组
 * 按照fof数量排序
 * @author 12285
 *
 */
public class User implements WritableComparable<User> {
	private String userName;
	private int fofNum;
	public User() {
	}
	public User(String userName, int fofNum){
		this.userName = userName;
		this.fofNum = fofNum;
	}	
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public int getFofNum() {
		return fofNum;
	}
	public void setFofNum(int fofNum) {
		this.fofNum = fofNum;
	}
	@Override
	public void write(DataOutput out) throws IOException {
		out.writeUTF(userName);
		out.writeInt(fofNum);
	}
	@Override
	public void readFields(DataInput in) throws IOException {
		this.userName = in.readUTF();
		this.fofNum = in.readInt();
	}
	@Override
	public int compareTo(User u) {
		int r1 = this.userName.compareTo(u.getUserName()) ;
		if (r1 ==0 ) {
			return Integer.compare(this.fofNum, u.getFofNum());
		}
		return r1;
	}
}
